//
//  OrderManageViewController.m
//  FactorySale
//
//  Created by 李 on 2020/1/1.
//  Copyright © 2020 主事丫环. All rights reserved.
//

#import "OrderManageViewController.h"
#import "UndeliveredOrderViewController.h"
#import "UnPaidViewController.h"
#import "HistoricalDeliveryOrderViewController.h"
#import "SGPagingView.h"

#define TYPEHEIGHT 0
@interface OrderManageViewController ()<UIScrollViewDelegate,SGPageTitleViewDelegate, SGPageContentScrollViewDelegate>

@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentScrollView *pageContentScrollView;
// 未发货订单
@property (nonatomic, strong)UndeliveredOrderViewController *oneVC;
// 未付款订单
@property (nonatomic, strong)UnPaidViewController *secondVC;
//历史发货订单
@property (nonatomic, strong)HistoricalDeliveryOrderViewController *thirdVC;
@property (nonatomic, assign) NSInteger currentVCIndex;
@end

@implementation OrderManageViewController
{
    NSInteger  pageIndex;
}
- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
//    //通知监听
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshRequest) name:shengChengFaHuoDanSucccessed object:nil];
//    //通知监听
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshRequest2) name:shengChengFaHuoDanWeiFuKuanSucccessed object:nil];
}
//-(void)refreshRequest
//{
//    self.currentVCIndex = 2;
//    [self.pageContentScrollView setPageContentScrollViewCurrentIndex:self.currentVCIndex];
//}
//-(void)refreshRequest2
//{
//    self.currentVCIndex = 1;
//    [self.pageContentScrollView setPageContentScrollViewCurrentIndex:self.currentVCIndex];
//}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"订单管理";
    self.view.backgroundColor = Main_BackGroundColor;
   
    [self copnfigPageTitleView];
 
}
-(void)copnfigPageTitleView
{
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    //    configure.indicatorFixedWidth = 30;
    configure.titleGradientEffect = YES;
    
    configure.titleSelectedColor= [UIColor colorWithHexString:@"#31CEA9"];
    configure.titleColor= [UIColor colorWithHexString:@"#999999"];
    configure.showIndicator = YES;
    configure.indicatorColor = zhutiColor;
    configure.bottomSeparatorColor= [UIColor whiteColor];
    
    NSMutableArray *titleArr = [NSMutableArray arrayWithCapacity:1];
    NSMutableArray *childVCS = [NSMutableArray arrayWithCapacity:1];
    [titleArr addObject:@"未发货订单"];
    [titleArr addObject:@"未付款订单"];
    [titleArr addObject:@"历史发货单"];
    //未发货订单
    self.oneVC = [UndeliveredOrderViewController new];
    [childVCS addObject:self.oneVC];
    // 未付款订单
    self.secondVC = [UnPaidViewController new];
    [childVCS addObject:self.secondVC];
    //历史发货订单
    self.thirdVC = [HistoricalDeliveryOrderViewController new];
    [childVCS addObject:self.thirdVC];
    
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, kNaviHeight, KWIDTH, 44) delegate:self titleNames:titleArr configure:configure];
    self.pageTitleView.backgroundColor =[UIColor colorWithHexString:@"#FFFFFF"];
    self.pageContentScrollView = [[SGPageContentScrollView alloc] initWithFrame:CGRectMake(0, kNaviHeight+44+TYPEHEIGHT+10, KWIDTH, KHEIGHT-kNaviHeight-44-TYPEHEIGHT-10) parentVC:self childVCs:childVCS];
    
    _pageContentScrollView.delegatePageContentScrollView = self;
    [self.view addSubview:self.pageTitleView ];
    
    [self.view addSubview:_pageContentScrollView];
}
#pragma mark - UIScrollViewDelegate
- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentScrollView setPageContentScrollViewCurrentIndex:selectedIndex];
}

- (void)pageContentScrollView:(SGPageContentScrollView *)pageContentScrollView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}

- (void)pageContentScrollView:(SGPageContentScrollView *)pageContentScrollView index:(NSInteger)index {
    self.currentVCIndex = index;
  
}

@end
